package com.zhangzeqin.code.controller;

import com.zhangzeqin.code.service.AdminService;
import com.zhangzeqin.code.service.Impl.AdminServiceImpl;

import java.sql.SQLException;

public class AdminController {
    /**
     * 实例化一个AdminService对象
     */
    AdminService adminService=new AdminServiceImpl();

    //构造器


    public AdminController() {
    }

    public AdminController(AdminService adminService) {
        this.adminService = adminService;
    }


    /**
     * 列出用户信息
     */
    public Object[][] listUser(){
        return adminService.listUser();
    }


    /**
     * 添加单词书
     * @param bookName
     * @return boolean结果
     */
    public boolean addBook(String bookName,String nature) {
        return adminService.addBook(bookName,nature);
    }

    /**
     * 管理员登录
     * @param name
     * @param password
     * @return boolean结果
     */
    public boolean landing(String name, String password ,String table) {
        return adminService.landing(name,password,table);
    }

    /**
     * 列出所有单词书
     */
    public Object[][] listBook(){
        return adminService.listBook();
    }

    /**
     * 重载,获得所有单词书的属性值 nature
     */
    public Object[] nature(){
        return adminService.nature();
    }
    /**
     * 列出所有某本单词书的单词
     */
    public Object[][] listWord(String bookName){
        return adminService.listWord(bookName);
    }

    /**
     * 获得公告内容
     */
    public Object getNotice()throws SQLException {
        return adminService.getNotice();
    }

    /**
     * 发布公告
     * @param notice 获取文本框的公告
     */
    public boolean publishNotice(String notice){
        return adminService.publishNotice(notice);
    }
}
